package main

import (
	_ "github.com/xgggh/test/api/routers"
	"github.com/astaxie/beego"
	"os"
	_"github.com/astaxie/beego/config"
	_"github.com/xgggh/test/api/db"
	_"github.com/xgggh/test/api/session"

	"github.com/xgggh/test/api/controllers"
)


const (
	dev = "dev"
	test = "test"
	prod ="prod"
)
func main() {
	if len(os.Args)>1&& os.Args[1]!="" {
		beego.BConfig.RunMode= os.Args[1]
	}else{
		beego.BConfig.RunMode= dev
	}
	if !(beego.BConfig.RunMode == dev ||
		beego.BConfig.RunMode == test||
		beego.BConfig.RunMode == prod) {
		panic("must go run main.go dev|test|prod")
	}
	beego.SetStaticPath("/html", "web/html")
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
	}
	beego.Router("/",&controllers.IndexController{})
	beego.Run()
}
